﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace e_TeachNext
{
    public partial class Course : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack) {
                try
                {
                    lblUserID.Text = Application["UserID"].ToString();
                    lblStudentNo.Text = Request.Cookies["Login"]["StudentNo"];
                    lblDuration.Text = "-";
                    lblFee.Text = "-";
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
            }
        }

        protected void ddlCourse_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlCourse.SelectedIndex == 1) {
                lblDuration.Text = "4 Months";
                lblFee.Text = "$250";
            }
            else if (ddlCourse.SelectedIndex == 2)
            {
                lblDuration.Text = "6 Months";
                lblFee.Text = "$350";
            }
            else if (ddlCourse.SelectedIndex == 3)
            {
                lblDuration.Text = "5 Months";
                lblFee.Text = "$300";
            }
            else {
                lblDuration.Text = "-";
                lblFee.Text = "-";
            }
            lbtnShowCalendar.Focus();
        }

        protected void lbtnShowCalendar_Click(object sender, EventArgs e)
        {
            Calendar1.Visible = true;
        }

        protected void Calendar1_SelectionChanged(object sender, EventArgs e)
        {
            txtStartDate.Text = Calendar1.SelectedDate.Date.ToLongDateString();
            Calendar1.Visible = false;
            btnOK.Focus();
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            Session.Add("CourseName",ddlCourse.Text);
            Session.Add("CourseDuration",lblDuration.Text);
            Session.Add("CourseFee",lblFee.Text);
            Session.Add("CourseStartDate",txtStartDate.Text);
            Response.Redirect("Admisstion.aspx");
        }
    }
}